package cn.sunxyz.enums;

import java.util.function.Supplier;

/**
 * Created by yangrd on 2017/5/27.
 */
public enum SizeCreateEnum {
    SMALL(new Supplier<ISize>() {
        @Override
        public ISize get() {
            return new ISize() {
                {
                    System.out.println("CREATE");
                }

                @Override
                public void size() {
                    System.out.println("小号");
                }
            };
        }
    }
    ), MEDIUM(() -> () ->
            System.out.println("中号")
    ), LARGE(() -> new LargeSize()), DEFAULT(SizeImpl::new);

    SizeCreateEnum(Supplier<ISize> sizeSupplier) {
        this.sizeSupplier = sizeSupplier;
    }

    private Supplier<ISize> sizeSupplier;

    public ISize getISize() {
        return sizeSupplier.get();
    }

    static class LargeSize implements ISize {

        {
            System.out.println("CREATE LARGE");
        }

        @Override
        public void size() {
            System.out.println("大号");
        }
    }
}
